<!DOCTYPE html>
<%@ page import="domain.misc.Misc, svc.MiscSvc,domain.repro.ReproMisc, constants.Constants;" %>
<%
	String userName="";
	if(request.getSession().getAttribute("name")!=null){
		userName=request.getSession().getAttribute("name").toString();
	}
	if(!userName.equals("")) {
		String fileNo=(String)session.getAttribute("fileNo");
		Misc misc = (Misc) request.getAttribute("misc");
		ReproMisc repromisc = (ReproMisc) request.getAttribute("repromisc");
		
		
		double kg = Constants.KG;
		double lbs = Constants.LBS;		
		double unit=0, p_calf=0, p_fixed_other=0, p_other_dry=0,p_other_lact=0, p_tmrdmdry=0,p_tmrdmlac=0, dmi_dry=0, p_semen=0;
		
		double[]vetcost=new double[4];
		vetcost=misc.getVetcost();
		
		unit=misc.getUnit();
		//out.print(unit);
		p_calf=misc.getP_calf();
		//out.print(p_calf);
		p_fixed_other=misc.getP_fixed_other();
		p_other_dry=misc.getP_other_dry();
		p_other_lact=misc.getP_other_lact();
		p_tmrdmdry=misc.getP_tmrdmdry();
		p_tmrdmlac=misc.getP_tmrdmlac();
		dmi_dry=misc.getDmi_dry();
		p_semen=repromisc.getP_semen();
%>
<html lang="en">
  <head>
    <title>Set Values</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="../css/bootstrap.css" rel="stylesheet">
    <link href="../css/bootstrap-responsive.css" rel="stylesheet">
     <link href="../css/docs.css" rel="stylesheet">
<link href="../css/google-code-prettify/prettify.css" rel="stylesheet">
    <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    
    
    
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
	  
	  
	
    </style>
   

    
   
  </head>

  <body onload="weightFix()">

    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
        <a class="brand" href="#">DairyVIP Project</a>
          <div class="nav-collapse collapse">
            <p class="navbar-text pull-right">
              Logged in as <a href="#" class="navbar-link"><%=userName%></a>
            </p>
            <ul class="nav">
              <li ><a href="../jsp/index.jsp">Home</a></li>
              <li><a href="../jsp/acknowledgements_contro.jsp">Acknowledgements/Contributors</a></li>
            <li><a href='../jsp/dataset.jsp'>My DairyVIP</a></li>
            </ul>
          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>
<div class="container"> 
    <div class="pagination pagination-left">
    <ul>
    <li class="active"><a href="#">Misc</a></li>
    <li><a href="../jsp/inputPrice">Price</a></li>
    <li><a href="../jsp/inputMilk" >Milk</a></li>
    <li><a href="../jsp/inputCull">Cull</a></li>
    <li><a href="../jsp/inputRepro">Repro</a></li>
    <li><a href="../jsp/inputBW">Bodyweight</a></li>
    </ul>
</div>

</div>    
     
  <div class="container1">
 <form id="saveMisc" name="saveMisc" method="post">
  
  <legend><small> MISCELLANEOUS</small></legend>  
  
     <input class="btn" type="button" onclick="save(this.form)" value="Save" />
     <input class="btn" type="button" onclick="saveAnalyze(this.form)" value="Save and Analyze" /><p></p>
  <table  cellspacing="0" cellpadding="1" style="background-color: #f5f5f5; border:#CCC solid 1px; font-size:12px ">
  		<tr>
  			<td style="border:#CCC solid 1px" >Units</td>
  			
  			<td style="border:#CCC solid 1px">
  				<input style="display:none" id="unitSelected" name="unitSelected" value="<%=unit%>"></input>
  				<select id="units" name="units" class="span_1" onChange="unitChange()" autocomplete="off" >
	  				<option value=<%=kg%>>KG</option>
	  				<option value=<%=lbs%>>LBS</option>
  				</select>
  			</td>
  		</tr> 
  		<tr>
           <td style="border:#CCC solid 1px" >Price Calf At Birth ($/calf)</td>

           <td style="border:#CCC solid 1px" ><input type="text" id="p_calf" name="p_calf" value =<%=p_calf%> size="5"  class= "span1"   style=" width:35px; height:15px; font-size:90%"     /></td>
         </tr>
         <tr>
           <td style="border:#CCC solid 1px" >Fixed Other Cost ($/slot/day)</td>
           <!--<td style="border:#CCC solid 1px" align="center">2.00</td>-->
           <td style="border:#CCC solid 1px" ><input type="text" id="p_fixed_other" name="p_fixed_other" value =<%=p_fixed_other%> size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%"  /></td>
         </tr>
         <tr>
           <td style="border:#CCC solid 1px" >Other Variable Cost Dry Cows ($/cow/day)</td>
            <td style="border:#CCC solid 1px" ><input type="text" id="p_other_dry"  name="p_other_dry" value =<%=p_other_dry%> size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%"  /></td>
         </tr>
         <tr>
           <td style="border:#CCC solid 1px" >Other Variable Cost Lactating Cows ($/cow/day)</td>
           <td style="border:#CCC solid 1px" ><input type="text"  id="p_other_lact" name="p_other_lact" value =<%=p_other_lact%> size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%" /></td>
         </tr>
         
       <!--  <tr><td style="border:#CCC solid 1px">Milk yield below which to cull nonpregnant cows (kg/day)</td>   <td style="border:#CCC solid 1px" ><input type="text" name="table14" value ="0" size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%" /></td></tr>-->
            <tr>
           <td style="border:#CCC solid 1px" >1st Month In Lactation ($/cow) </td>

           <td style="border:#CCC solid 1px" ><input type="text" id="vetcost1" name="vetcost1" value =<%=vetcost[1]%> size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%"  /></td>
         </tr>
         <tr>
           <td style="border:#CCC solid 1px" >2nd Month In Lactation ($/cow) </td>
   
           <td style="border:#CCC solid 1px" ><input type="text" id="vetcost2" name="vetcost2" value =<%=vetcost[2]%> size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%" /></td>
         </tr>
         <tr>
           <td style="border:#CCC solid 1px" >3rd Month In Lactation ($/cow) </td>

           <td style="border:#CCC solid 1px" ><input type="text" id="vetcost3" name="vetcost3" value =<%=vetcost[3]%> size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%"  /></td>
         </tr>
         <tr>
           <td style="border:#CCC solid 1px">>=4 Month In Lactation ($/cow) </td>

           <td style="border:#CCC solid 1px" ><input type="text" id="vetcost4" name="vetcost4" value =<%=vetcost[4]%> size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%"  /></td>
         </tr>
          <tr>
           <td style="border:#CCC solid 1px" >Feed Cost Lactating Cows <span id="p_tmrdmlac_kg" style="display:inline">($/kg dry matter)</span> <span id="p_tmrdmlac_lbs" style="display:none">($/lbs dry matter)</span> </td>

           <td style="border:#CCC solid 1px" ><input type="text" name="p_tmrdmlac" id="p_tmrdmlac" value =<%=p_tmrdmlac%> autocomplete="off" size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%" /></td>
         </tr>
         <tr>
           <td style="border:#CCC solid 1px" >Feed Cost Dry Cows <span id="p_tmrdmdry_kg" style="display:inline">($/kg dry matter)</span> <span id="p_tmrdmdry_lbs" style="display:none">($/lbs dry matter)</span> </td>

           <td style="border:#CCC solid 1px" ><input type="text" name="p_tmrdmdry" id ="p_tmrdmdry" value =<%=p_tmrdmdry%> autocomplete="off" size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%"  /></td>
         </tr><tr><td style="border:#CCC solid 1px">Dry Matter Intake Dry Cows 
		<span id="dmi_dry_kg" style="display:inline">(kg/cow/day)</span> <span id="dmi_dry_lbs" style="display:none">(lbs/cow/day)</span> </td>

           <td style="border:#CCC solid 1px" ><input type="text" id="dmi_dry" name="dmi_dry" value =<%=dmi_dry%> autocomplete="off"  size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%" /></td>
         </tr>
<tr><td style="border:#CCC solid 1px">Cost per insemination ($)</td>

           <td style="border:#CCC solid 1px" ><input type="text" id="p_semen" name="p_semen" value =<%=p_semen%> autocomplete="off"  size="5" class= "span1"   style=" width:35px; height:15px; font-size:90%" /></td>
         </tr>         
         
         
 </table>
 
   </form>


          <ul class="pager">
    <li><a href="../jsp/dataset.jsp">Previous</a></li>
    <li><a href="../jsp/input1_price.jsp">Next</a></li>
    </ul>
       </div>
<script language="javascript">
			function weightFix(){
				var unit = document.getElementById("unitSelected").value;
				var drpdwn = document.getElementById("units");
				//alert("Unit: "+unit);
				if (1 == unit){
					drpdwn.options[0].selected = true;
				}else{
					drpdwn.options[1].selected = true;
					unitChange();
				}
			}
			function save(form)/*function to check userid & password*/
			{
				form.action = '../jsp/saveMisc';
				form.submit();
				return true;
			}
			function saveAnalyze(form)/*function to check userid & password*/
			{
				form.action = '../jsp/saveAnalyzeMisc';
				form.submit();
				return true;
			}
		</script>            

      <footer class="footer">
       <%@ include file="../inc/footer.html" %>
      </footer>

   <!--/.fluid-container-->

    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    
 
  <script type="text/javascript" src="../js/jquery.js"></script>
  <script src="../js/bootstrap.js"></script>
 
<script language="javascript">  
function unitChange(){
	if(document.getElementById("units").value==1){
		document.getElementById("p_tmrdmlac").value = document.getElementById("p_tmrdmlac").value / <%=lbs%>;
		document.getElementById("p_tmrdmlac_kg").style.display="inline";
		document.getElementById("p_tmrdmlac_lbs").style.display="none";
		
		document.getElementById("p_tmrdmdry").value = document.getElementById("p_tmrdmdry").value / <%=lbs%>;
		document.getElementById("p_tmrdmdry_kg").style.display="inline";
		document.getElementById("p_tmrdmdry_lbs").style.display="none";
		
		document.getElementById("dmi_dry").value = document.getElementById("dmi_dry").value / <%=lbs%>;
		document.getElementById("dmi_dry_kg").style.display="inline";
		document.getElementById("dmi_dry_lbs").style.display="none";
	}else{
		document.getElementById("p_tmrdmlac").value = document.getElementById("p_tmrdmlac").value * <%=lbs%>;
		document.getElementById("p_tmrdmlac_lbs").style.display="inline";
		document.getElementById("p_tmrdmlac_kg").style.display="none";
		
		document.getElementById("p_tmrdmdry").value = document.getElementById("p_tmrdmdry").value * <%=lbs%>;
		document.getElementById("p_tmrdmdry_lbs").style.display="inline";
		document.getElementById("p_tmrdmdry_kg").style.display="none";
		
		document.getElementById("dmi_dry").value = document.getElementById("dmi_dry").value * <%=lbs%>;
		document.getElementById("dmi_dry_lbs").style.display="inline";
		document.getElementById("dmi_dry_kg").style.display="none";
	}
}

</script>

 
  </body>
</html>
<%}else
	out.print("Please <a href='../jsp/login.jsp'>log in</a> first!");
%>